package com.sofa.api.client.permission.fallback;

import com.sofa.api.client.logging.LoggingClient;
import com.sofa.api.client.permission.PermissionClient;
import com.sofa.api.dto.permission.UserRoleDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;


@Slf4j
public class PermissionClientFallBack implements FallbackFactory<PermissionClient> {
    @Override
    public PermissionClient create(Throwable cause) {
        log.error("调用权限服务出现异常", cause);
        return new PermissionClient() {

            @Override
            public void bindDefaultRole(Long userId) {

            }

            @Override
            public String getUserRoleCode(Long userId) {
                return null;
            }

            @Override
            public List<Long> getUserIdsByRolesCode(String roleCode) {
                return null;
            }

            @Override
            public void upgradeToAdmin(Long userId) {

            }

            @Override
            public void downgradeToUser(Long userId) {

            }

            @Override
            public List<UserRoleDTO> getUserRoleByUserIds(List<Long> userIds) {
                return null;
            }
        };
    }
}
